import time

import json

from . import ws


@ws.route("/test_conn")
def test_connect(sc):
    print("connect")
    while not sc.closed:
        time.sleep(2)
        t = time.strftime('%M:%S', time.localtime())
        sc.send(t)


@ws.route("/test")
def test(sc):
    while not sc.closed:
        time.sleep(2)
        list = []
        list.append({"abc": "hello"})
        list.append({"adc": "he222o"})
        sc.send(json.dumps(list))
